package com.want.evenchat.model.db;

import android.content.Context;
import com.want.evenchat.model.dao.ContactTableDAO;
import com.want.evenchat.model.dao.InviteTableDAO;

/**
 * Created by Want on 2018/5/6.
 */

public class DBManager {
    //联系人和邀请信息表的操作类的管理类

    private final DBHelper dbHelper;
    private final ContactTableDAO contactTableDAO;
    private final InviteTableDAO inviteTableDAO;


    public DBManager(Context context , String name) {
        //创建数据库
        dbHelper = new DBHelper(context, name);

        //创建该数据库中两张表的操作类
        contactTableDAO = new ContactTableDAO(dbHelper);
        inviteTableDAO = new InviteTableDAO(dbHelper);
    }

    //获取联系人表的操作类对象
    public ContactTableDAO getContactTableDAO(){
        return contactTableDAO;
    }

    //获取邀请信息表的操作类对象
    public InviteTableDAO getInviteTableDAO(){
        return inviteTableDAO;
    }

    //关闭数据库的方法
    public void close() {
        dbHelper.close();
    }
}
